package testers;

import java.util.ArrayList;

import db.DataBaseUtil;
import utils.Article;
import utils.ExtendedURL;
import utils.SingleArticleGrader;
import utils.SingleTokenizerAndPOSer;
import utils.Token;

import utils.HTMLCleanrClass;


public class TesterOfHTMlCleaner {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ExtendedURL url=new ExtendedURL(null,null,null);
		ArrayList<ExtendedURL> urlArr=new ArrayList<ExtendedURL>();
		//urlArr.add("http://www.clapper.org/software/java/util/install.shtml");
		//urlArr.add("http://www.fool.com/investing/general/2010/02/23/a-big-upgrade-for-art-technology-group.aspx");
		url.setUrl("http://www.fool.com/investing/general/2010/02/23/a-big-upgrade-for-art-technology-group.aspx");
		urlArr.add(url);
		HTMLCleanrClass hc=new HTMLCleanrClass();
		ArrayList<Article> docArr=hc.getTextFromHtml(urlArr);
		printDocs(docArr);
		SingleTokenizerAndPOSer.tokenizeAndPOS(docArr.get(0));
		printTokens(docArr.get(0));
		SingleArticleGrader grader=new SingleArticleGrader();
		docArr.get(0).setCompany(DataBaseUtil.getCompanyByTicker("AMZN"));
		grader.gradeArticle(docArr.get(0));
		System.out.println("************TT*********************");
		System.out.println(docArr.get(0).getTaggedText());
		System.out.println(docArr.get(0).getGrade());
		System.out.println("************TT*********************");
		//printTokens(docArr.get(0));
		//printDocs(docArr);
	}

	//for debug
	private static void printDocs(ArrayList<Article> docArr) {
		for (Article doc:docArr){
			System.out.println(doc.getOriginalText());
			System.out.println("--------------------------------------------");
		}
		
	}
	
	private static void printTokens(Article doc) {
		for (Token t:doc.getTokenedText()){
			System.out.println("WORD: "+t.getWord()+" POS: "+t.getPOS());
		}
		System.out.println("---------------------------------------------------");
		
	}
	
	private static void printTaggedDocs(ArrayList<Article> docArr) {
		for (Article doc:docArr){
			System.out.println(doc.getTaggedText());
			System.out.println("--------------------------------------------");
		}
		
	}

}
